﻿using System;
using System.Threading;

namespace Zeus.Concurrency.ZThread
{
    public delegate void CallBackDelegate(string message);

    public class ThreadWithState
    {
        private string message;
        // 回调委托
        private CallBackDelegate callback;

        // 构造函数
        public ThreadWithState(string message, CallBackDelegate callbackDelegate)
        {
            this.message = message;
            this.callback = callbackDelegate;
        }

        // 线程方法
        public void ThreadProc()
        {
            Thread.Sleep(5000);
            if (callback != null) callback("Complete");  // 通过委托, 将数据回传给回调函数
        }
    }
}
